package com.liao.ticket.controller;

import com.liao.ticket.service.UserService;
import com.liao.ticket.vo.Result;
import com.liao.ticket.vo.UserVo;
import com.liao.ticket.vo.params.LoginParams;
import com.liao.ticket.vo.params.UserParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 在用户验证成功后，提供给用户的接口
 * 接口测试成功
 * 1.0.0
 * 10.13 23:50
 */
@RestController
@RequestMapping("user")
public class UserController {

    @Autowired
    private UserService userService;

    // 获取 个人信息
    @GetMapping("info")
    public Result selectInfo() {
        UserVo userVo = userService.userVoSelfInfo();
        return Result.success(userVo);
    }

    // 修改 个人信息
    @PostMapping("update")
    public Result updateInfo(@RequestBody UserParams userParams) {
        return userService.updateSelfInfo(userParams);
    }

    // 修改 密码
    @PostMapping("update/pass")
    public Result updateSelfPass(@RequestBody LoginParams loginParams) {
        return userService.updateSelfPass(loginParams);
    }

    // 删除 个人账号 将从数据库删除
    @GetMapping("delete")
    public Result deleteSelfAccount(@RequestHeader String Token) {
        return userService.deleteSelfAccount(Token);
    }
}
